package com.jun.basic.controller;

import com.jun.basic.domain.User;
import com.jun.basic.service.impl.UserServiceImpl;
import com.jun.basic.utils.JsonData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/api/v1/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @PostMapping("/login")
    public JsonData<String> login(@RequestBody User user) {
        String token = userService.login(user.getUserName(), user.getPwd());
        log.info("tokem:{}", token);
        return token != null ? JsonData.buildSuccess(token) : JsonData.buildFail("密码错误");
    }

}
